<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<div id="ddd"></div>
<script src="js/template-web.js"></script>
<script type="text/html" id="tdl">
  <div>
    <span>姓名：{{@ name}}</span>
    <span>年龄: {{age}}</span>
    <span>年龄: {{$imports.dateFormat(date)}}</span>
  </div>
</script>
<script>
  var data={
    name:'<b>李四</b>',
    age:30,
    date:new Date()
  }

  var html =template('tdl',data);
  function dateFormat(date){
    return date.getFullYear()+'年'+(date.getMonth()+1)+'月'+date.getDate()+'日';
  }
  document.getElementById("ddd").innerHTML=html;
</script>

</body>
</html>